package com.guoq.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;

import com.guoq.mapper.UserMapper;
import com.guoq.pojo.User;
import com.guoq.service.IUserService;


@Service("userService")
public class UserServiceImpl implements IUserService {
	@Resource
	private UserMapper userMapper;
	@Resource(name = "taskExecutor")
    private TaskExecutor taskExecutor;
	
	@Override
	public User getUserById(int userId) {
		// TODO Auto-generated method stub
		return this.userMapper.selectByPrimaryKey(userId);
	}
	
	@Override
	public List<User> getUserAll(){
		return this.userMapper.selectAll();
	}

	@Override
	public int insertSelective(User record) {
//		try {
//	        taskExecutor.execute(new Runnable() {
//	          private int v_count=0;
//	          public void run() {
//	        	  userDao.insertSelective(record);
//	        	  setV_count(getV_count() + 1);
//	          }
//			public int getV_count() {
//				return v_count;
//			}
//			public void setV_count(int v_count) {
//				this.v_count = v_count;
//			}
//	        });
//	    } catch (Exception e) {
//	        e.printStackTrace();
//	    }
		
		// TODO Auto-generated method stub
		return this.userMapper.insertSelective(record);
	}

	@Override
	public int insert(User record) {
		// TODO Auto-generated method stub
		return this.userMapper.insert(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return this.userMapper.deleteByPrimaryKey(id);
	}
}
